package android.FiltrosJava;

import android.graphics.Bitmap;

public class MirrorVertical extends Filtro{

	public Bitmap applyFilter(Bitmap bmp) {
		int[] pixels;
		int height = bmp.getHeight();
		int width = bmp.getWidth();
		pixels = new int[height * width];
		bmp.getPixels(pixels, 0, width, 0, 0, width, height);
		int aux;
		int jump = 0;
		int lim = width;
		int i = 0;
		int t1 = i;
		int end = (width * height) - width;
		int t2 = end;

		while (jump < height / 2) {
			aux = pixels[t1];
			pixels[t1] = pixels[t2];
			pixels[t2] = aux;
			t1++;
			t2++;
			i++;
			if (i == lim) {
				jump++;
				end = (width * height - width) - jump * width;
				t1 = i;
				t2 = end;
				lim += width;
			}
		}
		bmp.setPixels(pixels, 0, width, 0, 0, width, height);
		pixels = null;
		return bmp;
	}

	@Override
	public int[] applyFilter(int[] pixels) {
		//int[] pixels;
		int height = Filtro.hei;
		int width = Filtro.wid;
		pixels = new int[height * width];
		//bmp.getPixels(pixels, 0, width, 0, 0, width, height);
		int aux;
		int jump = 0;
		int lim = width;
		int i = 0;
		int t1 = i;
		int end = (width * height) - width;
		int t2 = end;

		while (jump < height / 2) {
			aux = pixels[t1];
			pixels[t1] = pixels[t2];
			pixels[t2] = aux;
			t1++;
			t2++;
			i++;
			if (i == lim) {
				jump++;
				end = (width * height - width) - jump * width;
				t1 = i;
				t2 = end;
				lim += width;
			}
		}
		//bmp.setPixels(pixels, 0, width, 0, 0, width, height);
		return pixels;// = null;
		//return bmp;
	}
	
}